<?php
/**
 * Contact Form Widget
 */
function webtreats_contact_form_widget($args) {
	$email_address = get_option("widget_contactform");
	$email_adress_reciever = $email_address['email'] != "" ? $email_address['email'] : get_option('admin_email');
	$loader_style = $args['name'] == "Sidebar" ? 'loadingImgWidgetSb' : 'loadingImgWidgetFt';
	
	echo $args['before_widget'];
	echo $args['before_title'] .'Email Us'. $args['after_title'];
	
//If the form is submitted
if(isset($_POST['submittedWidget'])) {
	require(WEBTREATS_INCLUDES . "/submit-widget.php");
}
?>

<?php if(isset($emailSent) && $emailSent == true) { ?>
	<a name="_contact"></a> 
		<p class="thanks"><strong>Thanks!</strong> Your email was successfully sent.</p>

<?php } else { ?>
	
		<?php if(isset($captchaError)) { ?>
			<a name="_contact"></a>
			<p class="error">There was an error submitting the form.<p>
		<?php } ?>
		<a name="_contact"></a> 
		<form action="<?php the_permalink(); ?>#_contact" id="contactFormWidget" method="post">
			<p><input type="text" name="contactNameWidget" id="contactNameWidget" value="<?php if(isset($_POST['contactNameWidget'])) echo $_POST['contactNameWidget'];?>" class="requiredField textfield<?php if($nameError != '') {echo ' inputError';} ?>" size="22" tabindex="5" /><label class="textfield_label" for="contactNameWidget">Name *</label></p>

			<p><input type="text" name="emailWidget" id="emailWidget" value="<?php if(isset($_POST['emailWidget']))  echo $_POST['emailWidget'];?>" class="requiredField email textfield<?php if($emailError != '') {echo ' inputError';} ?>" size="22" tabindex="6" /><label class="textfield_label" for="emailWidget">Email *</label></p>

			<p><textarea name="commentsWidget" id="commentsTextWidget" rows="20" cols="30" tabindex="7" class="requiredField textarea<?php if($commentError != '') {echo ' inputError';} ?>"><?php if(isset($_POST['commentsWidget'])) { if(function_exists('stripslashes')) { echo stripslashes($_POST['commentsWidget']); } else { echo $_POST['commentsWidget']; } } ?></textarea></p>

			<p class="screenReader"><label for="checkingWidget" class="screenReader">If you want to submit this form, do not enter anything in this field</label><input type="text" name="checkingWidget" id="checkingWidget" class="screenReader" value="<?php if(isset($_POST['checking']))  echo $_POST['checking'];?>" /></p>


			<p class="loadingImgWidget" style="display:none;"><img src="<?php echo WEBTREATS_IMAGES; ?>/classic-loader.gif" alt="" /></p>
			<p><button name="submittedWidget" id="submittedWidget" type="submit" class="fancy_button" tabindex="8" value="Submit" ><span>Submit</span></button></p>
			<p class="screenReader"><input id="submitUrlWidget" type="hidden" name="submitUrlWidget" value="<?php echo get_template_directory_uri() . '/lib/includes/submit-widget.php'; ?>" /></p>
			<p class="screenReader"><input id="emailAddressWidget" type="hidden" name="emailAddressWidget" value="<?php echo webtreats_nospam($email_adress_reciever); ?>" /></p>

		</form>
<?php
	}
	echo $args['after_widget'];
}

function webtreats_contact_form_widget_admin() {
	$settings = get_option("widget_contactform");

	// check if anything's been sent
	if (isset($_POST['update_email'])) {
		$settings['email'] = strip_tags(stripslashes($_POST['contact_email']));

		update_option("widget_contactform",$settings);
	}

	echo '<p>
			<label for="contact_email">Email Address:
			<input id="contact_email" name="contact_email" type="text" class="widefat" value="'.$settings['email'].'" /></label></p>';
	echo '<input type="hidden" id="update_email" name="update_email" value="1" />';

}
wp_register_sidebar_widget( 'contact-form-widget', $themename.' - Contact Form', 'webtreats_contact_form_widget', array('description' => 'Email contact form for sidebar'));
register_widget_control('contact-form-widget', 'webtreats_contact_form_widget_admin', 400, 200);

/**
 * Sub Nav Class
 */
class Webtreats_SubNav_Widget extends WP_Widget {
    /** constructor */
    function Webtreats_SubNav_Widget() {
		global $themename;
        $widget_ops = array('classname' => 'webtreats_subnav_widget', 'description' => __( "Displays a list of SubPages") );
		$control_ops = array('width' => 250, 'height' => 200);
		$this->WP_Widget('subnav', __($themename.' - Sub Navigation'), $widget_ops, $control_ops);
    }

    function widget($args, $instance) {
		global $post, $page_exclusions;
        extract( $args );
		$parent = $post->post_parent;
		$title = apply_filters('widget_title', empty($instance['title']) ? get_the_title($parent) : $instance['title'], $instance, $this->id_base);
				
		if( is_search() || is_404() || is_archive() || is_single() ){ return; }	
		
      	echo $before_widget; 
	
        echo $before_title . $title . $after_title;

		$children = wp_list_pages("sort_column=menu_order&exclude=$page_exclusions&title_li=&child_of=".$parent."&echo=0&depth=1");
		echo '<ul>';
		echo $children;
		echo '</ul>';
	
 		echo $after_widget;

		}

    function update($new_instance, $old_instance) {				
	$instance = $old_instance;
	$instance['title'] = strip_tags($new_instance['title']);
        return $instance;
    }

    function form($instance) {				
        $title = esc_attr($instance['title']);
        ?>
            <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
			<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p>
        <?php 
    }

}

/**
 * Flick Widget Class
 */
class Webtreats_Flickr_Widget extends WP_Widget {
    /** constructor */
    function Webtreats_Flickr_Widget() {
		global $themename;
		$widget_ops = array('classname' => 'webtreats_flickr_widget', 'description' => __( "Pulls in images from your Flickr account.") );
		$control_ops = array('width' => 400, 'height' => 200);
		$this->WP_Widget('flickr', __($themename.' - Flickr'), $widget_ops, $control_ops);
    }

    function widget($args, $instance) {	
        extract( $args );
		$title = apply_filters('widget_title', empty($instance['title']) ? __('Photos on flickr') : $instance['title'], $instance, $this->id_base);
		$id = $instance['id'];
		
		if ( !$number = (int) $instance['number'] )
			$number = 3;
		else if ( $number < 1 )
			$number = 1;
		else if ( $number > 15 )
			$number = 15;
        ?>

			<?php echo $before_widget; ?>
				<?php echo $before_title . $title . $after_title; ?>
				<div class="flickr_wrap">
					<script type="text/javascript" src="http://www.flickr.com/badge_code_v2.gne?count=<?php echo $number; ?>&amp;display=latest&amp;size=s&amp;layout=x&amp;source=user&amp;user=<?php echo $id; ?>"></script> 
				</div>
			<?php echo $after_widget; ?>

        <?php
    }

    function update($new_instance, $old_instance) {				
        $instance = $old_instance;
		$instance['title'] = strip_tags($new_instance['title']);
		$instance['id'] = strip_tags($new_instance['id']);
		$instance['number'] = (int) $new_instance['number'];

		return $instance;
    }

    function form($instance) {
		$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
		$id = isset($instance['id']) ? esc_attr($instance['id']) : '';
		if ( !isset($instance['number']) || !$number = (int) $instance['number'] )
			$number = 3;
        ?>

		<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
		<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p>

		<p><label for="<?php echo $this->get_field_id('id'); ?>">Flickr ID (<a href="http://www.idgettr.com" target="_blank">idGettr</a>):</label>
		<input class="widefat" id="<?php echo $this->get_field_id('id'); ?>" name="<?php echo $this->get_field_name('id'); ?>" type="text" value="<?php echo $id; ?>" /></p>
			
		<p><label for="<?php echo $this->get_field_id('number'); ?>">Number of photos:</label>
		<input class="widefat" id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" /></p>

        <?php 
    }

}

/**
 * Twitter Widget Class
 */
class Webtreats_Twitter_Widget extends WP_Widget {
    /** constructor */
    function Webtreats_Twitter_Widget() {
		global $themename;
		$widget_ops = array('classname' => 'webtreats_twitter_widget', 'description' => __( "Pulls in your most recent tweet from Twitter.") );
		$control_ops = array('width' => 250, 'height' => 200);
		$this->WP_Widget('twitter', __($themename.' - Twitter'), $widget_ops, $control_ops);
    }

    function widget($args, $instance) {
		global $shortname;
        extract( $args );
		$title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Tweets') : $instance['title'], $instance, $this->id_base);
		$id = $instance['id'];
		
		if ( !$number = (int) $instance['number'] )
			$number = 5;
		else if ( $number < 1 )
			$number = 1;
		else if ( $number > 15 )
			$number = 15;
		
		$limit = $number;
		$type = 'widget';
        ?>

			<?php echo $before_widget; ?>
				<?php echo $before_title . $title . $after_title; ?>
					<div class="twitter_bird"></div>
						<ul>
							<?php echo parse_cache_twitter_feed($id, $limit, $type); ?>
						</ul>
			<?php echo $after_widget; ?>

        <?php
    }

    function update($new_instance, $old_instance) {	
		$instance = $old_instance;
		$instance['title'] = strip_tags($new_instance['title']);
		$instance['id'] = strip_tags($new_instance['id']);
		$instance['number'] = (int) $new_instance['number'];
				
        return $instance;
	
				
    }

    function form($instance) {
		$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
		$id = isset($instance['id']) ? esc_attr($instance['id']) : '';
		if ( !isset($instance['number']) || !$number = (int) $instance['number'] )
			$number = 5;
        ?>

		<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
		<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p>

		<p><label for="<?php echo $this->get_field_id('id'); ?>">Enter your twitter username:</label>
		<input class="widefat" id="<?php echo $this->get_field_id('id'); ?>" name="<?php echo $this->get_field_name('id'); ?>" type="text" value="<?php echo $id; ?>" /></p>
			
		<p><label for="<?php echo $this->get_field_id('number'); ?>">Enter the number of tweets you'd like to display:</label>
		<input class="widefat" id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" /></p>

        <?php 
    }

}

/**
 * Popular Post Widget Class
 */
class Webtreats_PopularPost_Widget extends WP_Widget {
    /** constructor */
    function Webtreats_PopularPost_Widget() {
		global $themename;
		$widget_ops = array('classname' => 'popular-widget', 'description' => __( "Custom popular post widget with post preview image.") );
		$control_ops = array('width' => 250, 'height' => 200);
		$this->WP_Widget('popularwidget', __($themename.' - Popular Post'), $widget_ops, $control_ops);
    }

    function widget($args, $instance) {
		global $wpdb;
        extract( $args );
		$title = apply_filters('widget_title', empty($instance['title']) ? __('Popular Posts') : $instance['title'], $instance, $this->id_base);
		
		if ( !$number = (int) $instance['number'] )
			$number = 3;
		else if ( $number < 1 )
			$number = 1;
		else if ( $number > 15 )
			$number = 15;
			
		$disable_thumb = $instance['disable_thumb'] ? '1' : '0';
		
		$pop_posts =  $number;
		
		$now = gmdate("Y-m-d H:i:s",time());
		$lastmonth = gmdate("Y-m-d H:i:s",gmmktime(date("H"), date("i"), date("s"), date("m")-12,date("d"),date("Y")));
		$popularposts = "SELECT ID, post_title, post_date, COUNT($wpdb->comments.comment_post_ID) AS 'stammy' FROM $wpdb->posts, $wpdb->comments WHERE comment_approved = '1' AND $wpdb->posts.ID=$wpdb->comments.comment_post_ID AND post_status = 'publish' AND post_date < '$now' AND post_date > '$lastmonth' AND comment_status = 'open' GROUP BY $wpdb->comments.comment_post_ID ORDER BY stammy DESC LIMIT ".$pop_posts;
		$posts = $wpdb->get_results($popularposts);
		$popular = '';

		echo $before_widget;
		echo $before_title . $title . $after_title;

		if($posts){ ?>

		<ul class="thumbnail_list">
			<?php foreach($posts as $post){ 
					$post_title = stripslashes($post->post_title);
					$post_date = $post->post_date;
					$post_date = mysql2date('m-j-Y', $post_date, false);
					$get_year = get_the_time('Y', $post->ID); $get_month = get_the_time('m', $post->ID);
					$permalink = get_permalink($post->ID);
					$meta_image = get_post_meta($post->ID, "post_image", true);
					if(!$meta_image){
						$meta_image = get_template_directory_uri() .'/styles/_shared/default_post_thumb_small.png';
					}else{
						
						if(preg_match_all('!.+\.(?:jpe?g|png|gif)!Ui',$meta_image,$matches)){
							$meta_image = webtreats_image_resize($img_height=60, $img_width=60, $meta_image);	
						}
						
						if( ( preg_match_all('#http://(www.vimeo|vimeo)\.com(/|/clip:)(\d+)(.*?)#i',$meta_image,$matches) ) || ( preg_match( '#http://(www.youtube|youtube|[A-Za-z]{2}.youtube)\.com/(.*?)#i', $meta_image, $matches ) ) ){
							$meta_image = get_template_directory_uri() .'/styles/_shared/default_movie_thumb_small.png';	
						}
					}
				?>
			<li>
				<?php if(!$disable_thumb) { ?>
				<a class="alignleft" href="<?php echo $permalink; ?>" title="<?php echo $post_title; ?>">
				<span class="small_frame"><img class="fade_hover" src="<?php echo $meta_image; ?>" width="60" height="60" alt="<?php echo $post_title; ?>"/></span></a>
				<?php } ?>
				
				<a class="thumbnail_title" href="<?php echo $permalink; ?>" rel="bookmark"><?php echo $post_title; ?></a><br/>
				<a class="date" href="<?php echo get_month_link($get_year, $get_month); ?>"><?php echo $post_date; ?></a>
				<div class="clearboth"></div>
			</li>
				<?php } ?>
		</ul>
			<?php }
			
		echo $after_widget;
    }

    function update($new_instance, $old_instance) {
		$instance = $old_instance;
		$instance['title'] = strip_tags($new_instance['title']);
		$instance['number'] = (int) $new_instance['number'];
		$instance['disable_thumb'] = !empty($new_instance['disable_thumb']) ? 1 : 0;
				
        return $instance;
    }

    function form($instance) {
		$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
		$disable_thumb = isset( $instance['disable_thumb'] ) ? (bool) $instance['disable_thumb'] : false;
		if ( !isset($instance['number']) || !$number = (int) $instance['number'] )
			$number = 3;
        ?>

		<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
		<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p>
		
		<p><label for="<?php echo $this->get_field_id('number'); ?>">Enter the number of popular posts you'd like to display:</label>
		<input class="widefat" id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" /></p>
		
		<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('disable_thumb'); ?>" name="<?php echo $this->get_field_name('disable_thumb'); ?>"<?php checked( $disable_thumb ); ?> />
		<label for="<?php echo $this->get_field_id('disable_thumb'); ?>"><?php _e( 'Disable Post Thumbnail?' ); ?></label></p>

        <?php
    }

}

/**
 * Recent Post Widget Class
 */
class Webtreats_RecentPost_Widget extends WP_Widget {
    /** constructor */
    function Webtreats_RecentPost_Widget() {
		global $themename;
		$widget_ops = array('classname' => 'custom-recent-widget', 'description' => __( "Custom recent post widget with post preview image.") );
		$control_ops = array('width' => 250, 'height' => 200);
		$this->WP_Widget('recentposts', __($themename.' - Recent Post'), $widget_ops, $control_ops);
    }

    function widget($args, $instance) {
		global $wpdb, $shortname;
        extract( $args );
		$title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts') : $instance['title'], $instance, $this->id_base);
		
		if ( !$number = (int) $instance['number'] )
			$number = 3;
		else if ( $number < 1 )
			$number = 1;
		else if ( $number > 15 )
			$number = 15;
			
		$disable_thumb = $instance['disable_thumb'] ? '1' : '0';
		
		$get_options = get_option($shortname.'_general_settings');
		$blog_excludecats = $get_options['blog_excludecats'];
		$exclude_blog_cats = preg_replace("!(\d)+!","-${0}$0", $blog_excludecats);
		$posts = get_posts("cat=$exclude_blog_cats&numberposts=$number&offset=0");

		echo $before_widget;
		echo $before_title . $title . $after_title;

		if($posts){ ?>

		<ul class="thumbnail_list">
			<?php foreach($posts as $post){
					$post_title = stripslashes($post->post_title);
					$post_date = $post->post_date;
					$post_date = mysql2date('m-j-Y', $post_date, false);
					$get_year = get_the_time('Y', $post->ID); $get_month = get_the_time('m', $post->ID);
					$permalink = get_permalink($post->ID);
					$meta_image = get_post_meta($post->ID, "post_image", true);
					if(!$meta_image){
						$meta_image = get_template_directory_uri() .'/styles/_shared/default_post_thumb_small.png';
					}else{
						
						if(preg_match_all('!.+\.(?:jpe?g|png|gif)!Ui',$meta_image,$matches)){
							$meta_image = webtreats_image_resize($img_height=60, $img_width=60, $meta_image);	
						}
						
						if( ( preg_match_all('#http://(www.vimeo|vimeo)\.com(/|/clip:)(\d+)(.*?)#i',$meta_image,$matches) ) || ( preg_match( '#http://(www.youtube|youtube|[A-Za-z]{2}.youtube)\.com/(.*?)#i', $meta_image, $matches ) ) ){
							$meta_image = get_template_directory_uri() .'/styles/_shared/default_movie_thumb_small.png';	
						}
					}
				?>
			<li>
				<?php if(!$disable_thumb) { ?>
				<a class="alignleft" href="<?php echo $permalink; ?>" title="<?php echo $post_title; ?>">
				<span class="small_frame"><img class="fade_hover" src="<?php echo $meta_image; ?>" width="60" height="60" alt="<?php echo $post_title; ?>"/></span></a>
				<?php } ?>
				
				<a class="thumbnail_title" href="<?php echo $permalink; ?>" rel="bookmark"><?php echo $post_title; ?></a><br/>
				<a class="date" href="<?php echo get_month_link($get_year, $get_month); ?>"><?php echo $post_date; ?></a>
				<div class="clearboth"></div>
			</li>
				<?php } ?>
		</ul>
			<?php }	
			
		echo $after_widget;
    }

    function update($new_instance, $old_instance) {				
        	$instance = $old_instance;
		$instance['title'] = strip_tags($new_instance['title']);
		$instance['number'] = (int) $new_instance['number'];
		$instance['disable_thumb'] = !empty($new_instance['disable_thumb']) ? 1 : 0;
				
        return $instance;
    }

    function form($instance) {				
		$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
		$disable_thumb = isset( $instance['disable_thumb'] ) ? (bool) $instance['disable_thumb'] : false;
		if ( !isset($instance['number']) || !$number = (int) $instance['number'] )
			$number = 3;
        ?>

		<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
		<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p>

		<p><label for="<?php echo $this->get_field_id('number'); ?>">Enter the number of recent posts you'd like to display:</label>
		<input class="widefat" id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" /></p>

		<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('disable_thumb'); ?>" name="<?php echo $this->get_field_name('disable_thumb'); ?>"<?php checked( $disable_thumb ); ?> />
		<label for="<?php echo $this->get_field_id('disable_thumb'); ?>"><?php _e( 'Disable Post Thumbnail?' ); ?></label></p>

        <?php 
    }

}

/**
 * Contact Widget Class
 */
class Webtreats_Contact_Widget extends WP_Widget {
    /** constructor */
    function Webtreats_Contact_Widget() {
		global $themename;
		$widget_ops = array('classname' => 'contact-widget', 'description' => __( "Quickly add contact info to your sidebar (e.g. address, phone #, email).") );
		$control_ops = array('width' => 400, 'height' => 200);
		$this->WP_Widget('contact', __($themename.' - Contact Us'), $widget_ops, $control_ops);
    }

    function widget($args, $instance) {
        extract( $args );
        $title = apply_filters('widget_title', empty($instance['title']) ? __('Contact Info') : $instance['title'], $instance, $this->id_base);
		$name = $instance['name'];
		$address = $instance['address'];
		$city = $instance['city'];
		$state = $instance['state'];
		$zip = $instance['zip'];
		$phone = $instance['phone'];
		$email = $instance['email'];
	    ?>
	
            <?php echo $before_widget; ?>

			<?php echo $before_title . $title . $after_title; ?>
			
			<?php if ( $name ) : ?>
			<span class="contact_widget_name"><?php echo $name; ?></span><br /> <?php endif; ?>

			<?php if ( $address ) : ?>
			<span class="contact_widget_address"><?php echo $address; ?></span><br /> <?php endif; ?>

			<?php if ( $city ) : ?>
			<span class="contact_widget_city"><?php echo $city; ?>,&nbsp;<?php echo $state; ?></span>&nbsp; <?php endif; ?>

			<?php if ( $zip ) : ?>
			<span class="contact_widget_zip"><?php echo $zip; ?></span><br /> <?php endif; ?>

			<?php if ( $phone ) : ?>
			<span class="contact_widget_phone"><?php echo $phone; ?></span><br /> <?php endif; ?>

			<?php if ( $email ) : ?>
			<span class="contact_widget_email"><a href="#" rel="<?php echo webtreats_nospam($email); ?>" class="email_widget"><?php echo webtreats_nospam($email); ?></a></span><br /> <?php endif; ?>

            <?php echo $after_widget;
	    }


    function update($new_instance, $old_instance) {
		$instance = $old_instance;
		
		$instance['title'] = strip_tags($new_instance['title']);
		$instance['name'] = strip_tags($new_instance['name']);
		$instance['address'] = strip_tags($new_instance['address']);
		$instance['city'] = strip_tags($new_instance['city']);
		$instance['state'] = strip_tags($new_instance['state']);
		$instance['zip'] = strip_tags($new_instance['zip']);
		$instance['phone'] = strip_tags($new_instance['phone']);
		$instance['email'] = strip_tags($new_instance['email']);
			
        return $instance;
    }

    function form($instance) {				
        $title = isset($instance['title']) ? esc_attr($instance['title']) : '';
		$name = isset($instance['name']) ? esc_attr($instance['name']) : '';
		$address = isset($instance['address']) ? esc_attr($instance['address']) : '';
		$city = isset($instance['city']) ? esc_attr($instance['city']) : '';
		$state = isset($instance['state']) ? esc_attr($instance['state']) : '';
		$zip = isset($instance['zip']) ? esc_attr($instance['zip']) : '';
		$phone = isset($instance['phone']) ? esc_attr($instance['phone']) : '';
		$email = isset($instance['email']) ? esc_attr($instance['email']) : '';
        ?>

		<p><label for="<?php echo $this->get_field_id('title'); ?>">Title:</label>
		<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p>

		<p><label for="<?php echo $this->get_field_id('name'); ?>">Name:</label>
		<input class="widefat" id="<?php echo $this->get_field_id('name'); ?>" name="<?php echo $this->get_field_name('name'); ?>" type="text" value="<?php echo $name; ?>" /></p>

		<p><label for="<?php echo $this->get_field_name('address'); ?>">Address:</label>
		<input class="widefat" id="<?php echo $this->get_field_id('address'); ?>" name="<?php echo $this->get_field_name('address'); ?>" type="text" value="<?php echo $address; ?>" /></p>

		<p><label for="<?php echo $this->get_field_id('city'); ?>">City:</label>
		<input class="widefat" id="<?php echo $this->get_field_id('city'); ?>" name="<?php echo $this->get_field_name('city'); ?>" type="text" value="<?php echo $city; ?>" /></p>

		<p><label for="<?php echo $this->get_field_id('state'); ?>">State:</label>
		<input class="widefat" id="<?php echo $this->get_field_id('state'); ?>" name="<?php echo $this->get_field_name('state'); ?>" type="text" value="<?php echo $state; ?>" /></p>

		<p><label for="<?php echo $this->get_field_id('zip'); ?>">Zip:</label>
		<input class="widefat" id="<?php echo $this->get_field_id('zip'); ?>" name="<?php echo $this->get_field_name('zip'); ?>" type="text" value="<?php echo $zip; ?>" /></p>

		<p><label for="<?php echo $this->get_field_id('phone'); ?>">Phone:</label>
		<input class="widefat" id="<?php echo $this->get_field_id('phone'); ?>" name="<?php echo $this->get_field_name('phone'); ?>" type="text" value="<?php echo $phone; ?>" /></p>

		<p><label for="<?php echo $this->get_field_name('email'); ?>">Email:</label>
		<input class="widefat" id="<?php echo $this->get_field_id('email'); ?>" name="<?php echo $this->get_field_name('email'); ?>" type="text" value="<?php echo $email; ?>" /></p>

        <?php
    }

}



// register widget classess
add_action('widgets_init', create_function('', 'return register_widget("Webtreats_SubNav_Widget");'));

add_action('widgets_init', create_function('', 'return register_widget("Webtreats_Flickr_Widget");'));
add_action('widgets_init', create_function('', 'return register_widget("Webtreats_Twitter_Widget");'));
add_action('widgets_init', create_function('', 'return register_widget("Webtreats_PopularPost_Widget");'));
add_action('widgets_init', create_function('', 'return register_widget("Webtreats_RecentPost_Widget");'));
add_action('widgets_init', create_function('', 'return register_widget("Webtreats_Contact_Widget");'));

?>